Generating Algebraic Laws from Imperative Programs
نویسنده
چکیده
The use of veri ers for proving the correctness of concrete programs is well known and has been amply described in the literature Here we focus on further perhaps more general tasks such veri ers can perform Given a program that is assumed to be correct we derive a set of axioms for the data structures involved In the simplest case we study an abstract program interchanging the contents of two variables The veri cation conditions generated by our veri er NPPV are a set of equations specifying quasigroups Other examples reveal the notion of strategy from the veri cation of an abstract game playing program or show the correspondence between inductive proofs of numeric properties and veri cation of a program searching for a counterexample Finally we apply NPPV on Wand s example showing the incompleteness of Hoare s logic We also give a simpli ed proof of Wand s result Algorithm Data Structure Control According to standard de nitions an algorithm is a detailed and explicit instruction for the stepwise solution of a given problem This means that there must be given a repertoire of elementary or atomic steps which are to be com bined according to the instructions of the algorithm In a general sense it is of course allowed to think of atomic steps such as add a cup of our stir and of combinations of instructions such as add a cup of our then stir until smooth but we shall not deal with recipes rather with algorithms computing functions over sets of data Here an atomic step consists of calculating a data value according to a given set of operations and storing the result in a memory cell In describing how to combine such elementary steps a small set of instructions including composition conditional if then else and loops while or repeat is commonly used This way a separation of concerns is achieved A data structure de nes the admissible atomic steps and a control structure determines how these steps are to be combined to yield the desired algorithm This view is stated very succinctly in the well known slogan algorithm data structure control The border separating data structure and control may slide towards either side depending on the application As an example we may assume to have multiplica tion of natural numbers available as elementary arithmetical instruction yet we may also get by with the operators of Presburger arithmetic succ and construct an algorithm for multiplication All programming languages provide mechanisms to augment the data structure by such de ned functions The main purpose of this article is a demonstration together with a set of some succinct examples that show how Wirth s equation may be solved for an unknown data structure too That is given the speci cation of an algorithm and given a control structure automatically determine axioms for a data struc ture required to ful l the speci cation A vehicle for nding these examples is a program veri er NPPV that we have constructed for educational purposes and used in many courses on program veri cation With its help we can not only semi automatically verify concrete programs but also investigate abstract pro grams and reveal relationships between programs speci cations invariants and data structure requirements As a simple example for instance we shall show that a program to interchange the value of two variables works correctly pre cisely if the data structure contains a quasigroup operation or that the failure of a program to nd a counterexample to a conjecture leads to an induction axiom for the data type NPPV New Paltz Program Veri er has been implemented on an IBM com patible PC and has been developed for and successfully used in courses devoted to the mathematics of program veri cation and abstract data types The software is embedded in an integrated development environment with built in editor pull down menus and pop up windows It is freely available for demonstration and course use
منابع مشابه
Programming Research Group an Algebraic Semantics for Nondeterministic Choice
Our book Algebraic Semantics of Imperative Programs uses the algebraic speci cation language OBJ to give a formal semantics to a simple imperative programming language, using a theory of abstract machines that associate integer values with the variables of the programming language. In this paper we extend the semantics to programs with a nondeterministic choice operation. Speci cally, we introd...
متن کاملLaws of Programming for References
We propose a set of algebraic laws for reasoning with sequential imperative programs that use object references like in Java. The theory is based on previous work by adding laws to cope with object references. The incrementality of the algebraic method is fundamental; with a few exceptions, existing laws for copy semantics are entirely reused, as they are not affected by the proposed laws for r...
متن کاملAutomated Invariant Generation by Algebraic Techniques for Imperative Program Verification in Theorema Automated Invariant Generation by Algebraic Techniques for Imperative Program Verification in Theorema
This thesis presents algebraic and combinatorial approaches for reasoning about imperative loops with assignments, sequencing and conditionals. A certain family of loops, called P-solvable, is defined for which the value of each program variable can be expressed as a polynomial of the initial values of variables, the loop counter, and some new variables where there are algebraic dependencies am...
متن کاملLazy Relations
We present a relational model of non-strict computations in an imperative, non-deterministic context. Undefinedness is represented independently of non-termination. The relations satisfy algebraic properties known from other approaches to model imperative programs; we introduce additional laws that model dependence in computations in an elegant algebraic form using partial orders. Programs can ...
متن کاملImperative abstractions for functional actions
We elaborate our relational model of non-strict, imperative computations. The theory is extended to support infinite data structures. To facilitate their use in programs, we extend the programming language by concepts such as procedures, parameters, partial application, algebraic data types, pattern matching and list comprehensions. For each concept, we provide a relational semantics. Abstracti...
متن کاملAlgebraic Frameworks for Probabilistic and Concurrent Systems
Formal methods have been extensively used and studied in the area of theoretical computer science ultimately with the aim of providing the technical foundations to justify design methods for producing high quality software systems. Formal methods provide a way to write specifications of required behaviour together with rules to check that the implementation’s behaviour is consistent with that o...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- Theor. Comput. Sci.
دوره 217 شماره
صفحات -
تاریخ انتشار 1999